package com.business.action.weixin;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.business.bean.oa.DispatchUserApplyBean;
import com.business.bean.oa.DispatchWorkBean;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import net.sf.rose.jdbc.PageBean;
import net.sf.rose.jdbc.dao.BeanDAO;
import net.sf.rose.jdbc.query.BeanSQL;
import net.sf.rose.jdbc.service.Service;
import net.sf.rose.util.StringUtil;
import net.sf.rose.web.util.WebUtils;

@Controller
@RequestMapping("/weixin/work")
public class WeixinWorkAction {

	/**
	 * 派工申请 保存DispatchUserApplyBean表
	 */
	@ResponseBody
	@RequestMapping("/workerApply.do")
	public PageBean workerApply(Service service, String json) {
		PageBean page = new PageBean();
		BeanDAO dao = new BeanDAO(service);
		BeanSQL query = dao.getQuerySQL();
		List<DispatchUserApplyBean> list = StringUtil.parseJsonArray(DispatchUserApplyBean.class, json);
		return page;
	}

	/**
	 * 项目签到 保存DispatchWorkBean和DispatchWorkFile二张表;按工程和日期不能重复
	 */
	@ResponseBody
	@RequestMapping("/project/sign.do")
	public PageBean projectSign(Service service, DispatchWorkBean bean, String json) {
		PageBean page = new PageBean();
		BeanDAO dao = new BeanDAO(service);
		BeanSQL query = dao.getQuerySQL();
		return page;
	}

	/**
	 * 项目签到列表
	 */
	@ResponseBody
	@RequestMapping("/project/sign/list.do")
	public PageBean projectSignList(Service service, HttpServletRequest request) {
		PageBean page = WebUtils.getPageBean(request);
		Map<String, Object> map = WebUtils.getRequestData(request);
		BeanDAO dao = new BeanDAO(service);
		BeanSQL query = dao.getQuerySQL();
		query.setPage(page);
		query.setEntityClass(DispatchWorkBean.class);
		query.createSql(map);
		List<DispatchWorkBean> list = dao.list();
		// 加载图片
		return page;
	}

	/**
	 * 项目日报 保存DispatchWorkFile表
	 */
	@ResponseBody
	@RequestMapping("/project/dayReport.do")
	public PageBean projectDayReport(Service service) {
		PageBean page = new PageBean();
		BeanDAO dao = new BeanDAO(service);
		BeanSQL query = dao.getQuerySQL();
		return page;
	}

	/**
	 * 项目日报列表
	 */
	@ResponseBody
	@RequestMapping("/project/dayReport/list.do")
	public PageBean projectDayReportList(Service service) {
		PageBean page = new PageBean();
		BeanDAO dao = new BeanDAO(service);
		BeanSQL query = dao.getQuerySQL();
		return page;
	}
}
